package com.cp.yn.activity

import android.os.Bundle
import android.widget.LinearLayout
import com.common.base.base.BaseActivity
import com.cp.yn.databinding.ActivityWebviewBinding
import com.cp.yn.manager.RouterManager
import com.didi.drouter.annotation.Router
import com.just.agentweb.AgentWeb

@Router(path = RouterManager.Path.APP_WebView)
class WebViewActivity : BaseActivity<ActivityWebviewBinding>() {
    lateinit var mAgentWeb:AgentWeb

    override fun viewBinding(): ActivityWebviewBinding {
        return ActivityWebviewBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initWebView()
    }

    private fun initWebView() {
//        AgentWebConfig.clearDiskCache(this);
        mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent(viewBinding.webview as LinearLayout?, LinearLayout.LayoutParams(-1, -1))
            .useDefaultIndicator()
            .createAgentWeb()
            .ready()
            .go("http://www.jd.com")
    }

//    override fun onPause() {
//        super.onPause()
//        mAgentWeb.webLifeCycle.onPause()
//    }
//
//    override fun onResume() {
//        super.onResume()
//        mAgentWeb.webLifeCycle.onResume()
//    }
//
//    override fun onDestroy() {
//        super.onDestroy()
//        mAgentWeb.webLifeCycle.onDestroy()
//    }
}